/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package one_variable_quadratic;
import java.io.*;
import java.lang.*;
import java.math.*;


/**
 *
 * @author hhl
 */
public class One_variable_quadratic {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        double[] x=new double[]{0.0,0.0,0.0};
        System.out.println("请依次输入一元二次方程的三个系数a,b,c：（ax^2+bx+c=0）");

        String s="";
        for(int i=0;i<3;i++){
            try{
                BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
                s=in.readLine();
            }
            catch(IOException e){}
            x[i]=Double.parseDouble(s);
        }

        if((Math.pow(x[1],2)-4*x[0]*x[2])<0)
            System.out.println("方程无实根");
        else{
            System.out.println("方程"+x[0]+"x^2"+"+"+x[1]+"x"+"+"+x[2]+"=0的第一个根为："+((-x[1]+Math.sqrt(Math.pow(x[1],2)-4*x[0]*x[2]))/(2*x[0])));
            System.out.println("方程"+x[0]+"x^2"+"+"+x[1]+"x"+"+"+x[2]+"=0的第一个根为："+((-x[1]-Math.sqrt(Math.pow(x[1],2)-4*x[0]*x[2]))/(2*x[0])));
        }
    }

}
